package com.azt.model;

import java.util.Map;


/**
 * Ajax返回模板
 * @author vipdon
 *
 */
public class AjaxJson {

	private boolean success = true;// 是否成功
	private String msg = "操作成功";// 提示信息
	private Integer code;//错误码
	private Object obj = null;// 其他信息
	private Map<String, Object> attributes;// 其他参数
	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public static AjaxJson success(){
		return success(null);
	}
	public static AjaxJson success(String message){
		AjaxJson json  = new AjaxJson();
		json.success= true;
		json.msg = message;
		return json;
	}
	
	public static AjaxJson error(String msg){
		AjaxJson json  = new AjaxJson();
		json.success= false;
		json.msg = msg;
		return json;
	}

	public static AjaxJson error() {
		return error("操作失败");
	}
	
	public AjaxJson setAttributes(Map<String, Object> attributes) {
		this.attributes = attributes;
		return this;
	}

	public String getMsg() {
		return msg;
	}

	public AjaxJson setMsg(String msg) {
		this.msg = msg;
		return this;
	}

	public Object getObj() {
		return obj;
	}

	public AjaxJson setObj(Object obj) {
		this.obj = obj;
		return this;
	}

	public boolean isSuccess() {
		return success;
	}

	public AjaxJson setSuccess(boolean success) {
		this.success = success;
		return this;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}
}
